{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2. 计算函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = eval(input(\"输入x:\"))\n",
    "y = 0\n",
    "if x < -4:\n",
    "    y = x + 9\n",
    "elif x < 4:\n",
    "    y = x ** 2 + 2 * x + 1\n",
    "else:\n",
    "    y = 2 * x - 15\n",
    "print(y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 3. 判定成绩等级"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "n = eval(input(\"输入学生成绩:\"))\n",
    "if n < 60:\n",
    "    print(\"不及格\")\n",
    "elif n < 70:\n",
    "    print(\"及格\")\n",
    "elif n < 85:\n",
    "    print(\"良好\")\n",
    "else:\n",
    "    print(\"优秀\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 4. 计算优惠价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2550.0\n"
     ]
    }
   ],
   "source": [
    "n = eval(input(\"输入购物款数:\"))\n",
    "if 1000 <= n < 2000:\n",
    "    n *= 0.95\n",
    "elif n < 3000:\n",
    "    n *= 0.9\n",
    "elif n < 5000:\n",
    "    n *= 0.85\n",
    "else:\n",
    "    n *= 0.8\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 6. 最大公约数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3\n"
     ]
    }
   ],
   "source": [
    "a = int(input(\"输入1个整数:\"))\n",
    "b = int(input(\"再输入1个整数:\"))\n",
    "while a % b:\n",
    "    a, b = b, a % b\n",
    "print(b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 8. 菲波那切数列\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 "
     ]
    }
   ],
   "source": [
    "a,b = 1,1\n",
    "print(a,b,end=\" \")\n",
    "for i in range(18):\n",
    "    c = a+b\n",
    "    print(c,end=\" \")\n",
    "    a,b = b,c\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
